#pragma once

#include "DXAMLCommon.h"
#include "XamlSchemaContext.h"

#include "xamltypeinfoprovider.h"


class XamlManagedTypeInfoProvider :
	public XamlTypeInfoProvider
{
private: 
	XamlManagedTypeInfoProvider(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext);
	static HRESULT Create(const xshared_ptr<XamlSchemaContext> & inXamlSchemaContext, xshared_ptr<XamlManagedTypeInfoProvider> & outXamlManagedTypeInfoProvider);
public: 

	virtual HRESULT Initialize();
	virtual HRESULT ResolveAssembly(const xshared_ptr<CXString> & inAssemblyName, struct XamlAssemblyToken & outAssemblyToken);
	
	virtual HRESULT GetSourceAssembly(xshared_ptr<CXString> & outssSourceAssembly);

	virtual HRESULT GetTypeNamespacesForUri(const xshared_ptr<CXString> & inXmlNamespaceUri, struct XamlTypeNamespaceToken * * ppTypeNamespaceTokens, XUINT32 * pcTypeNamespaceTokens);
	virtual HRESULT GetTypeNamespace(const xshared_ptr<CXString> & inAssemblyName, const xshared_ptr<CXString> & inTypeNamespace, struct XamlTypeNamespaceToken & outTypeNamespaceToken);
	virtual HRESULT GetTypeNamespace(const xshared_ptr<CXString> & inTypeNamespace, struct XamlTypeNamespaceToken & outTypeNamespaceToken);
	virtual HRESULT GetTypeNamespaceForType(struct XamlTypeToken sXamlTypeToken, struct XamlTypeNamespaceToken & rXamlTypeNamespaceToken, xshared_ptr<CXString> & outXamlTypeNamespaceName);
	virtual HRESULT LookupTypeFlags(struct XamlTypeToken sTypeToken, const XamlBitSet<enum BoolTypeBits> & btbLookupValues, XamlBitSet<enum BoolTypeBits> & btbBitsChecked, XamlBitSet<enum BoolTypeBits> & btbReturnValues);
	virtual HRESULT LookupPropertyFlags(struct XamlPropertyToken sPropertyToken, const XamlBitSet<enum BoolPropertyBits> & bpbLookupValues, XamlBitSet<enum BoolPropertyBits> & bpbBitsChecked, XamlBitSet<enum BoolPropertyBits> & bpbReturnValues);
	virtual HRESULT ResolveTypeName(struct XamlTypeNamespaceToken inNamespaceToken, const xshared_ptr<CXString> & inTypeName, struct XamlTypeToken & rXamlType);
	virtual HRESULT ResolvePropertyName(struct XamlTypeToken sTypeToken, const xshared_ptr<CXString> & inPropertyName, struct XamlPropertyToken & outProperty, struct XamlTypeToken & outPropertyTypeToken);
	virtual HRESULT ResolveDependencyPropertyName(struct XamlTypeToken sTypeToken, const xshared_ptr<CXString> & inPropertyName, struct XamlPropertyToken & outProperty, struct XamlTypeToken & outPropertyTypeToken);
	virtual HRESULT GetTypeName(struct XamlTypeToken sTypeToken, xshared_ptr<CXString> & outTypeName);
	virtual HRESULT GetTypeFullName(struct XamlTypeToken sTypeToken, xshared_ptr<CXString> & outTypeFullName);
	virtual HRESULT GetPropertyName(struct XamlPropertyToken sPropertyToken, xshared_ptr<CXString> & outPropertyName);
	virtual HRESULT GetBaseType(struct XamlTypeToken sTypeToken, struct XamlTypeToken & rBaseTypeToken);
	virtual HRESULT GetDeclaringType(struct XamlPropertyToken sPropertyToken, struct XamlTypeToken & rDeclaringTypeToken);
	virtual HRESULT IsAssignableFrom(struct XamlTypeToken sDerivedTypeToken, struct XamlTypeToken rxtBaseType, XBOOL & bOut);
	virtual HRESULT GetContentProperty(struct XamlTypeToken sTypeToken, struct XamlPropertyToken & rPropertyToken, struct XamlTypeToken & rContentPropertyTypeToken);
	virtual HRESULT GetContentWrapper(struct XamlTypeToken sTypeToken, struct XamlTypeToken & rContentWrapperTypeToken);
	virtual HRESULT GetRuntimeNameProperty(struct XamlTypeToken sTypeToken, struct XamlPropertyToken & rPropertyToken, struct XamlTypeToken & rPropertyTypeToken);
	virtual HRESULT GetDictionaryKeyProperty(struct XamlTypeToken sTypeToken, struct XamlPropertyToken & rPropertyToken, struct XamlTypeToken & rPropertyTypeToken);
	virtual HRESULT GetXmlLangProperty(struct XamlTypeToken sTypeToken, struct XamlPropertyToken & rPropertyToken, struct XamlTypeToken & rPropertyTypeToken);
	virtual HRESULT GetCollectionItemType(struct XamlTypeToken sCollectionTypeToken, struct XamlTypeToken & rCollectionItemTypeToken);
	virtual HRESULT GetTextSyntaxForType(struct XamlTypeToken sTypeToken, struct XamlTypeToken & rsTextSyntaxTypeToken);
	virtual HRESULT GetTextSyntaxForProperty(struct XamlPropertyToken sPropertyToken, struct XamlTypeToken & rsTextSyntaxTypeToken);
private: 
	HRESULT GetCore(CCoreServices * * ppCore); 
	HRESULT GetSchemaContext(xshared_ptr<XamlSchemaContext> & outSchemaContext);
	xweak_ptr<XamlSchemaContext> m_spXamlSchemaContext;
};
